package model;

import java.util.ArrayList;
import java.util.Date;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

public class FlyEmployee extends Model
{
	private Fly			fly;
	private Employee	employee;
	private boolean		specified;
	private Date		start;
	private Date		end;
	private boolean		berlinLongDelay;
	private Fly			arriveFly;

	public FlyEmployee()
	{

	}

	@SuppressWarnings("unchecked")
	public static ArrayList<FlyEmployee> getFlyEmployeeByFly(Session session, Fly fly)
	{
		Criteria criteria = session.createCriteria(FlyEmployee.class);
		Criterion criterion = Restrictions.eq("fly", fly);
		criteria.add(criterion);
		return (ArrayList<FlyEmployee>) criteria.list();
	}

	@SuppressWarnings("unchecked")
	public static ArrayList<FlyEmployee> getFlyEmployeeByEmployee(Session session, Employee employee)
	{
		Criteria criteria = session.createCriteria(FlyEmployee.class);
		Criterion criterion = Restrictions.eq("employee", employee);
		criteria.add(criterion);
		return (ArrayList<FlyEmployee>) criteria.list();
	}

	public static FlyEmployee getFlyEmployeeByFlyAndEmployee(Session session, Fly fly, Employee employee)
	{
		Criteria criteria = session.createCriteria(FlyEmployee.class);
		Criterion criterion = Restrictions.eq("employee", employee);
		Criterion criterion2 = Restrictions.eq("fly", fly);
		Criterion criterion3 = Restrictions.and(criterion, criterion2);
		criteria.add(criterion3);
		return (FlyEmployee) criteria.uniqueResult();
	}

	public Fly getFly()
	{
		return fly;
	}

	public void setFly(Fly fly)
	{
		this.fly = fly;
	}

	public Employee getEmployee()
	{
		return employee;
	}

	public void setEmployee(Employee employee)
	{
		this.employee = employee;
	}

	public boolean isSpecified()
	{
		return specified;
	}

	public void setSpecified(boolean specified)
	{
		this.specified = specified;
	}

	public Date getStart()
	{
		return start;
	}

	public void setStart(Date start)
	{
		this.start = start;
	}

	public Date getEnd()
	{
		return end;
	}

	public void setEnd(Date end)
	{
		this.end = end;
	}

	public Fly getArriveFly()
	{
		return arriveFly;
	}

	public void setArriveFly(Fly arriveFly)
	{
		this.arriveFly = arriveFly;
	}

	public boolean isBerlinLongDelay()
	{
		return berlinLongDelay;
	}

	public void setBerlinLongDelay(boolean berlinLongDelay)
	{
		this.berlinLongDelay = berlinLongDelay;
	}
}
